using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using Microsoft.AspNetCore.Mvc;
using YayiMgr.Ability.Docking.Commom;
using YayiMgr.Ability.Docking.UserApp;
using YayiMgr.Ability.Docking.UserApp.Dto;

namespace YayiMgr.Web.Users
{
    [ApiController]
    [Route("api/[controller]/[action]")]
    public class UserController : ControllerBase
    {
        public IUserServicer UserServicer { get; set; }

        [HttpPost]
        public async Task<QueryListDto<UserDto>> Get(UserQueryDto dto)
        {
            return await UserServicer.GetUsers(dto);
        }

        [HttpGet("{id}")]
        public async Task<ResponseDto<UserDto>> Get(Guid Id)
        {
            return await UserServicer.GetUserById(Id);
        }

        [HttpPost]
        public async Task<ResponseDto<UserDto>> Post(UserCreateDto dto)
        {
            return await UserServicer.AddUser(dto);
        }

        [HttpPut]
        public async Task Put(Guid Id, UserUpdateDto dto)
        {
            await UserServicer.UpdateUser(Id,dto);
        }

        [HttpDelete]
        public async Task Delete(Guid Id)
        {
            await UserServicer.DeleteUser(Id);
        }
    }
}